package com.training.java.core.collections.treeset.post15;

import java.util.Set;
import java.util.TreeSet;

import com.training.java.core.collections.car.pre15.Car;

public class CarTreeSetDemo  {

	public static void main(String[] args) {

		Car car1= new Car("toyota","corolla",2010);
		Car car2= new Car("Toyota","corolla",2010);
		//Car car2= new Car("Honda","CRV",2012);
		Car car3 = new Car("ford","Focus",2007);
		//Car car3 = new Car("Ford","Focus",2007);
		
		car1.setPrice(18000);
		car2.setPrice(18000);
		car3.setPrice(20000);
		
		Set<Car> setOfCars= new TreeSet<Car>();
		
		setOfCars.add(car1);
		setOfCars.add(car3);
		setOfCars.add(car2);
		setOfCars.add(car2);
		
		for(Car car:setOfCars)
		{
			System.out.println("Make :" + car.getMake() );
			System.out.println("Model :" + car.getModel() );
			System.out.println("Year :" + car.getYear() );
			System.out.println("price :" + car.getPrice() );
			System.out.println("*******************");
		}
		
		System.out.println("car1 and car2:"+ car1.compareTo(car2));
		System.out.println("car1 and car2:"+ car1.equals(car2));
		
	}

	

}
